﻿using System.Collections.Specialized;
using System.Text;

namespace Library.Gsm.AtCommands {
  public class OneLineStringCollection : StringCollection {
    public OneLineStringCollection() {
      ReplaceNewLine = ". ";
    }

    public string ReplaceNewLine { get; set; }

    public override string ToString() {
      var builder = new StringBuilder();
      for (int index = 0; index < Count; index++) {
        var text = this[index];
        if (index != 0) builder.Append(ReplaceNewLine);
        builder.Append(text);
      }

      return builder.ToString();
    }
    /*
     * return first line value if collection count is one, otherwise return null;
     */
    public string FirstLine {
      get {
        if (Count == 1) return this[0];
        return null;
      }
    }
  }
}
